package com.streambolics.worseminton.servlet;

import javax.servlet.http.HttpServletRequest;

import com.streambolics.worseminton.data.Event;

/**
 * The servlet that updates event information. This servlet assumes the event
 * already exists, contrary to the EventCreateHandler which tries to retrieve a
 * matching event, and creates it only if it does not yet exist.
 * 
 * @author Sauron
 * 
 */

public class EventUpdateHandler extends EventHandler
{
    private static final long serialVersionUID = 1L;

    @Override
    protected Event generateResponseObject (HttpServletRequest aRequest) throws Exception
    {
        Event e = getReferencedEvent ();
        if (requireWritePermission (e))
        {
            updateEvent (e);
            updateGuests (e);
            e.sendEmails ();
        }
        return e;
    }

    @Override
    protected String getRedirect (Event aResponseObject)
    {
        return aResponseObject.getIdUrl ("/go/Event");
    }
}
